package com.sojson.config.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import com.sojson.util.servlet.ServletUtil;

/**
 * 字符编码过滤器
 * 
 * @author liu
 * @date 2020-10-09
 */
public class CharacterEncodingFilter implements Filter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
        // 设置字符集
        ServletUtil.initCharacterEncoding(request, response);

        // 初始化响应头
        ServletUtil.initServletResponse(response);

        chain.doFilter(request, response);
    }

}